﻿namespace Huayou.UI.WebControls
{
    using System;
    using System.Web.UI;
    using System.Xml;

    internal class MenuGroupIE4 : MenuGroupRenderBase
    {
        public MenuGroupIE4(XmlElement node, WebMenu menu) : base(node, menu)
        {
        }

        protected string getCollapseEffect()
        {
            return "null";
        }

        public override void RenderEnd(HtmlTextWriter output)
        {
            output.RenderEndTag();
        }

        public override void RenderHorizontal(HtmlTextWriter output)
        {
            this.RenderStart(output);
            output.RenderBeginTag("tr");
            for (int i = 0; i < base.GroupNode.ChildNodes.Count; i++)
            {
                if ((base.GroupNode.ChildNodes[i].NodeType == XmlNodeType.Element) && (base.GroupNode.ChildNodes[i].Name == "MenuItem"))
                {
                    this.RenderItem(output, base.GroupNode.ChildNodes[i]);
                }
            }
            output.RenderEndTag();
            this.RenderEnd(output);
        }

        public override void RenderItem(HtmlTextWriter output, XmlNode itemNode)
        {
            MenuItemIE4 mie = new MenuItemIE4((XmlElement) itemNode, this, base.Menu);
            if (mie.IsVisible)
            {
                mie.Render(output);
            }
        }

        public override void RenderStart(HtmlTextWriter output)
        {
            string str2;
            if (base.useDefaultStyle())
            {
                output.AddAttribute("class", "aspnmG");
            }
            else if (base.CssClass != null)
            {
                output.AddAttribute("class", base.CssClass);
            }
            output.AddAttribute("cellspacing", base.ItemSpacing.ToString());
            if (base.ClientSideID != null)
            {
                output.AddAttribute("id", base.ClientSideID);
            }
            if (!base.IsTopGroup())
            {
                output.AddAttribute("style", "position:absolute;visibility:hidden;z-index:999;left:0px;top:0px;");
            }
            if (!(!base.IsTopGroup() || base.Menu.Width.IsEmpty))
            {
                output.AddAttribute("width", "100%");
            }
            else if (base.Width != null)
            {
                output.AddAttribute("width", base.Width.ToString());
            }
            if (!(!base.IsTopGroup() || base.Menu.Height.IsEmpty))
            {
                output.AddAttribute("height", "100%");
            }
            else if (base.Height != null)
            {
                output.AddAttribute("height", base.Height.ToString());
            }
            output.AddAttribute("cellpadding", "0");
            output.AddAttribute("border", "0");
            if (base.GroupNode.ParentNode.Name == "MenuItem")
            {
                string str = "aspnm_groupMsOver('" + base.ClientSideID + "')";
                str2 = (((("if (document.readyState == 'complete') aspnm_groupMsOut('" + base.ClientSideID + "', '") + base.GroupNode.ParentNode.Attributes["ClientSideID"].Value + "', '") + base.GroupNode.ParentNode.ParentNode.Attributes["ClientSideID"].Value + "', ") + base.Menu.ExpandDelay.ToString() + ", ") + this.getCollapseEffect() + ");";
                if (base.Menu.Enabled)
                {
                    output.AddAttribute("onmouseover", str);
                    output.AddAttribute("onmouseout", str2);
                }
            }
            else
            {
                str2 = string.Concat(new object[] { "if (document.readyState == 'complete') aspnm_groupMsOut('", base.ClientSideID, "', null, null, ", base.Menu.ExpandDelay, ");" });
                if (base.Menu.Enabled)
                {
                    output.AddAttribute("onmouseout", str2);
                }
            }
            output.AddStyleAttribute("z-index", "999");
            output.RenderBeginTag("table");
        }

        public override void RenderVertical(HtmlTextWriter output)
        {
            this.RenderStart(output);
            for (int i = 0; i < base.GroupNode.ChildNodes.Count; i++)
            {
                output.RenderBeginTag("tr");
                if ((base.GroupNode.ChildNodes[i].NodeType == XmlNodeType.Element) && (base.GroupNode.ChildNodes[i].Name == "MenuItem"))
                {
                    this.RenderItem(output, base.GroupNode.ChildNodes[i]);
                }
                output.RenderEndTag();
            }
            this.RenderEnd(output);
        }
    }
}

